﻿-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[proc_txcx_Select] 
	(
	@CompanyId VARCHAR(500),
	@StartDate NCHAR(10)	,
	@EndDate NCHAR(10),
	@StartIndex INT,
	@EndIndex int
	)
AS
BEGIN
	DECLARE @strsql VARCHAR (2000)
	SET @strsql='
	;WITH list as (
	SELECT ROW_NUMBER() OVER (ORDER BY createdate desc)AS Row,* FROM txcx t WHERE t.CompanyId IN ('+@CompanyId+') AND Convert(varchar(10),t.createdate,120) BETWEEN '''+@StartDate+''' AND '''+@EndDate+'''
	)
	
	select *,(select count(1) from list) as DataSum from list where row between '+ CONVERT(VARCHAR,@StartIndex)+' and '+CONVERT(VARCHAR, @EndIndex)+'
	
	'
--	PRINT(@strsql)
	EXEC (@strsql)
END
